﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Windows;

namespace QLKS.ViewModels
{
    static public class NguoiDungViewModel
    {
        static public DataTable GetAllNguoiDung(string columns)
        {
            DataTable tb = new DataTable();
            tb = Models.NguoiDungModel.GetAllNguoiDung(columns);
            return tb;
        }

        //Tạo mới Người dùng
        static public DataTable CreateNewNguoiDung()
        {
            DataTable tb = new DataTable();
            tb = Models.NguoiDungModel.CreateNewNguoiDung();
            return tb;
        }
        //Lấy danh sách nhân viên
        static public DataTable GetAllNguoiDung()
        {
            DataTable tb = new DataTable();
            tb = Models.NguoiDungModel.GetAllNguoiDung();
            return tb;
        }

        //Lấy nhóm nhân viên
        static public DataTable GetNhomNguoiDung()
        {
            DataTable tb = new DataTable();
            tb = Models.NguoiDungModel.GetNhomNguoiDung();
            return tb;
        }

        //thêm nhân viên
        static public bool ThemNguoiDung(DataTable tb)
        {
            try
            {
                Models.NguoiDungModel.ThemNguoiDung(tb);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "HotelManager", MessageBoxButton.OK, MessageBoxImage.Error);
                if (Models.DataProviderModel.IsOpen)
                    Models.DataProviderModel.Close();
                return false;
            }
            return true;
        }

        //Xóa người dùng
        static public bool XoaNguoiDung(string username)
        {
            try
            {
                Models.NguoiDungModel.XoaNguoiDung(username);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "HotelManager", MessageBoxButton.OK, MessageBoxImage.Error);
                if (Models.DataProviderModel.IsOpen)
                    Models.DataProviderModel.Close();
                return false;
            }
            return true;
        }

        //Kích hoạt người dùng
        static public bool KichHoatNguoiDung(string username)
        {
            try
            {
                Models.NguoiDungModel.KichHoatNguoiDung(username);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "HotelManager", MessageBoxButton.OK, MessageBoxImage.Error);
                if (Models.DataProviderModel.IsOpen)
                    Models.DataProviderModel.Close();
                return false;
            }
            return true;
        }

        //Khóa người dùng
        static public bool KhoaNguoiDung(string username)
        {
            try
            {
                Models.NguoiDungModel.KhoaNguoiDung(username);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "HotelManager", MessageBoxButton.OK, MessageBoxImage.Error);
                if (Models.DataProviderModel.IsOpen)
                    Models.DataProviderModel.Close();
                return false;
            }
            return true;
        }
    }
}
